#ifndef ANIMCREATURE_H
#define ANIMCREATURE_H

#include "Ogre.h"
#include "Util.h"

class AnimCreature;
class MovableObject;
class Leg
{

    public :
    Leg(AnimCreature* _parent, Ogre::Vector2 _start, Ogre::Vector2 _dif);

    ~Leg();


    void update(int _turnDirection);


    private:

    AnimCreature *m_parent;

    Ogre::Vector2 m_foot;
    Ogre::Vector2 m_footCenterRelative;// center of foot radius
    Ogre::Vector2 m_footCenter;// center of foot radius (absolute)
    Ogre::Vector2 m_attachPosition;// Point where we are attached to creature
    Ogre::Vector2 m_attachPositionRelative;
    Ogre::Vector2 m_goalPosition;

    float m_footVelocity;
    bool m_isWalking;
    int m_facing;// for step direction while turning- 1 for counterclockwise
    float m_baseAngle;

};



class AnimCreature
{
    friend class Leg;
    public:
        AnimCreature(MovableObject* _parent);
        virtual ~AnimCreature();

        void update(double timeSinceLastFrame);
        void init();



        void setPosition(Ogre::Vector3 _p){ m_position =_p ;};

        Ogre::Vector3 getDestination(){return m_destination;};
        void setDestination(Ogre::Vector3 _p){ m_destination =_p ;};

        float getDistanceFromDestination();
        float getAngleHeading();


    protected:
    private:


    Ogre::Vector3 m_position;
    Ogre::Vector3 m_currentPosition;
    Ogre::Vector3 m_destination;
    Ogre::Vector3 m_wobbleVelocity;

    std::vector<Leg> m_legs;

    float m_velocityAdjustWhenTurning;

    float m_heading;

    float m_turnRate;
    float m_velocity;

    MovableObject* m_parent;


        Ogre::Vector2 getPosition2D(){return removeYtoVector3(m_position);};
        Ogre::Vector3 getPosition(){return m_position;};


};

#endif // ANIMCREATURE_H
